<?php
/**
 * @file fashionwearproduct.php
 * @author LinLin
 * @date 2016年11月22日 上午11:51:02
 * @brief 
 */
namespace haibao\cms\data\fashionwear;

use haibao\cms\model\filter\activity\Activity as ActivityFilter;

class FashionWearProduct extends \haibao\cms\data\BaseMysql{

    public function __construct(){
        parent::__construct('\haibao\cms\model\data\fashionwear\FashionWearProduct');
    }
    
    public function getFashionWearProductByFilter($query){
       return $this->getAll($query);
    }

    /**
     * 保存时尚穿搭product表信息
     * @param unknown $fashionwearid 时尚穿搭id
     * @param unknown $productModel 对应的单品信息实体
     * @throws BusinessException
     */
    public function saveFashionWearProduct($fashionwearid,$productModel){
        $sql = 'delete from FashionWearProduct where FashionWearId = %s';
        $this->query($sql,array($fashionwearid));
        if($productModel && $productModel[0]){
            $this->addAll($productModel);
        }
    }
    
    /**
     * 通过时尚穿搭ID获得关联单品的排序信息
     * @param unknown $fashionWearId
     */
    public function getOneFashionWearProductByFashionId($fashionWearId){
        $sql = 'select * from FashionWearProduct where FashionWearId = %s';
        $result = $this->query($sql,array($fashionWearId));
        $fashionWearProduct = array();
        while($row = $result->fetch_assoc()){
            $fashionWearProduct[] = $row;
        }
        return $fashionWearProduct;
    }


    
}